<template>
	<div class="conPpageBox">
		<div class="navbar">
			<div class="hearderBoxIcon" @click="goBack">
				<img src="../../assets/images/fanhuijiantou.png" alt="">
			</div>
			<div class="title">{{$t('indexTitle.title29')}}</div>
			<div class="right"></div>
		</div>
		<div class="nrc-tabs">
			<div class="nrc-tabs-nav">
				<div class="nrc-tabs-tab" :class="tab == 0 ? 'active':''" @click="changetab(0)">
					{{$t('indexTitle.title234')}}
				</div>
				<!-- <div class="nrc-tabs-tab" :class="tab == 1 ? 'active':''" @click="changetab(1)">
					{{$t('indexTitle.title235')}}
				</div>
				<div class="nrc-tabs-tab" :class="tab == 2 ? 'active':''" @click="changetab(2)">
					{{$t('indexTitle.title236')}}
				</div> -->
				<div class="nrc-tabs-tab" :class="tab == 3 ? 'active':''" @click="changetab(3)">
					{{$t('indexTitle.title237')}}
				</div>
			</div>
			<div class="history-cards-wrapper" v-if="tab == 0">
				<!-- <div class="mission-period">
					{{$t('indexTitle.title147')}}:08:02:52
				</div> -->
				<div class="item" v-for="(it,index) in renWuList" :key="index">
					<div>
						<div class="mission-title">{{it.name}}</div>
						<div class="mission-threshold-progress">
							<span class="threshold-text"
								v-if="it.type==1">{{$t('indexTitle.title267')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==2">{{$t('indexTitle.title268')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==3">{{$t('indexTitle.title320')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==4">{{$t('indexTitle.title321')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==5">{{$t('indexTitle.title322')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==6">{{$t('indexTitle.title323')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==7">{{$t('indexTitle.title324')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==8">{{$t('indexTitle.title325')}}{{it.num}}</span>
							<span class="threshold-text"
								v-if="it.type==9">{{$t('indexTitle.title326')}}{{it.num}}</span>
							<div class="progress-box">
								<div class="progress-text">{{it.user_num}}/{{it.num}}</div>
								<!--  v-if="it.type==1" -->
								<!-- <div class="progress-text" v-if="it.type==2">{{chongzhilianInfo.maliang}}/{{it.num}}
								</div> -->
								<div class="progress-bar">
									<div class="progress-line" :style="{'width':it.widthSize}"></div>
									<div class="progress-line" style="width: 100%;" v-if="it.wanchen"></div>
								</div>
							</div>
						</div>
					</div>
					<div class="reward-row">
						<span v-if="it.type2==1">{{$t('indexTitle.title269')}} {{it.zhuanpangcishu}}
							{{$t('indexTitle.title270')}}</span>
						<span v-if="it.type2==2">{{$t('indexTitle.title319')}}￥{{it.zhuanpangcishu}}</span>
						<el-button v-if="!it.wanchen&&it.dabiao"
							@click="submitRenwu(it)">{{$t('indexTitle.title155')}}</el-button>
						<el-button v-if="!it.wanchen&&!it.dabiao"
							class="asdfas">{{$t('indexTitle.title272')}}</el-button>
						<div class="" v-if="it.wanchen">
							{{$t('indexTitle.title271')}}
						</div>
					</div>
				</div>
				<!-- <div class="item">
					<div>
						<div class="mission-title">{{$t('indexTitle.title152')}}</div>
						<div class="mission-threshold-progress">
							<span class="threshold-text">3{{$t('indexTitle.title153')}}</span>
							<div class="progress-box completed">
								<div class="progress-text">{{$t('indexTitle.title154')}}</div>
								<div class="progress-bar">
									<div class="progress-line" style="width: 100%;"></div>
								</div>
							</div>
						</div>
					</div>
					<div class="reward-row">
						<span>+ {{$t('indexTitle.title150')}} 3 {{$t('indexTitle.title151')}}</span>
						<el-button>{{$t('indexTitle.title155')}}</el-button>
					</div>
				</div> -->
			</div>
			<div class="history-cards-wrapper" v-if="tab == 1">
				<div class="mission-period">
					{{$t('indexTitle.title147')}}:08:02:52
				</div>
				<div class="item">
					<div>
						<div class="mission-title">{{$t('indexTitle.title148')}}</div>
						<div class="mission-threshold-progress">
							<span class="threshold-text">100 {{$t('indexTitle.title149')}}</span>
							<div class="progress-box">
								<div class="progress-text">0/100</div>
								<div class="progress-bar">
									<div class="progress-line" style="width: 0%;"></div>
								</div>
							</div>
						</div>
					</div>
					<div class="reward-row">
						<span>+ {{$t('indexTitle.title150')}} 3 {{$t('indexTitle.title151')}}</span>
					</div>
				</div>
				<div class="item">
					<div>
						<div class="mission-title">{{$t('indexTitle.title152')}}</div>
						<div class="mission-threshold-progress">
							<span class="threshold-text">3{{$t('indexTitle.title153')}}</span>
							<div class="progress-box completed">
								<div class="progress-text">{{$t('indexTitle.title154')}}</div>
								<div class="progress-bar">
									<div class="progress-line" style="width: 100%;"></div>
								</div>
							</div>
						</div>
					</div>
					<div class="reward-row">
						<span>+ {{$t('indexTitle.title150')}} 3 {{$t('indexTitle.title151')}}</span>
						<el-button>{{$t('indexTitle.title155')}}</el-button>
					</div>
				</div>
			</div>
			<div class="" v-if="tab == 3">
				<indexTow ref="indexTowThree"></indexTow>
			</div>
			<div class="history-cards-wrapper" v-if="tab == 2">
				<div class="no-data-container">{{$t('indexTitle.title156')}}</div>
			</div>
			<!-- <div class="buttons">
				<img src="../../assets/images/xiaoxi.png" alt="" />
			</div> -->
		</div>
		<!-- <div class="event-qmenu" :class="close ? 'close' : ''">
			<div class="handle" @click="close=!close">
				<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 70">
					<path
						d="M0,1.3l0,67.4c0.5-1.3,1.2-2.6,1.9-3.8c2-3.3,4.2-5.7,8.4-9.6l1.5-1.4C19.3,47,22,42.8,22,35s-2.7-12-10.2-18.9c-0.2-0.2-1.2-1.1-1.5-1.4c-4.2-3.9-6.5-6.3-8.4-9.6C1.2,3.9,0.5,2.6,0,1.3L0,1.3z">
					</path>
		
				</svg>
				<img src="../../assets/images/jiantoudsd.png" alt="" v-if="close">
				<img src="../../assets/images/jiantouxxx.png" alt="" v-if="!close">
			</div>
		
			<div class="cont">
				<div class="event-item" @click="getNextPage('/mission')">
					<img src="../../assets/images/1.webp" alt="" />
				</div>
				<div class="event-item">
					<img src="../../assets/images/2.png" alt="" />
				</div>
				<div class="event-item" @click="getNextPage('/turntable')">
					<img src="../../assets/images/3.webp" alt="" />
				</div>
			</div>
		</div> -->
		<loadingFour :msgText="msgTextTow" v-if="isShowLoadingTeow" @closeGuanbiTow="closeGuanbi"></loadingFour>
		<loadingThree v-if="isShowLoading"></loadingThree>
	</div>
</template>

<script>
	import Swiper from 'swiper';
	import indexTow from '../index/indexTow.vue';
	import loadingThree from '../../components/loadingThree.vue';
	import loadingFour from '../../components/loadingFour.vue';
	import {
		qiandaoTianshuList,
		qiandao,
		chongzhilian,
		renwuList,
		renwuSubmit
	} from "../../utils/api.js"
	export default {
		data() {
			return {
				tab: 0,
				close: true,
				qianbaoList: [],
				chongzhilianInfo: {},
				renWuList: [],
				isShowLoading: true,
				msgTextTow: "",
				isShowLoadingTeow: false
			}
		},
		components: {
			indexTow,
			loadingThree,
			loadingFour
		},
		created() {

		},
		mounted() {
			this.getqiandaoTianshuList();
			this.getchongzhilian();
			new Swiper("#swiper1", {
				direction: "horizontal",
				speed: 600,
				loop: true,
				autoplay: false,
				observer: true,
				observeParents: true,
				effect: "coverflow",
				slidesPerView: "auto",
				centeredSlides: true,
				coverflowEffect: {
					rotate: 0, //slide做3d旋转时Y轴的旋转角度。默认50。
					stretch: -5, //每个slide之间的拉伸值，越大slide靠得越紧。 默认0。
					depth: 20, //slide的位置深度。值越大z轴距离越远，看起来越小。 默认100。
					modifier: 5,
					slideShadows: false, //开启slide阴影。默认 true。
				},
			});

		},
		methods: {
			closeGuanbi(e) {
				this.isShowLoadingTeow = false;
			},
			getNextPage(page) {
				if (localStorage.getItem('token')) {
					this.$router.push(page)
				} else {
					this.$router.push('/login')
				}
			},
			getqiandaoTianshuList() {
				let data = {}
				qiandaoTianshuList(data).then((res) => {
					if (res.status.errorCode == 0) {
						this.isShowLoading = false;
						this.qianbaoList = res.data;

					} else {
						// this.$message.error(res.status.msg);
						this.msgTextTow = res.status.msg;
						this.isShowLoadingTeow = true;
						setTimeout(() => {
							this.isShowLoadingTeow = false;
						}, 2000)
						// this.$message({
						// 	showClose: true,
						// 	message: res.status.msg,
						// 	type: 'error'
						// });
					}
				}).catch((err) => {
					console.log(err, 'err')
				});
			},
			getchongzhilian() {
				let data = {}
				chongzhilian(data).then((res) => {
					if (res.status.errorCode == 0) {
						this.chongzhilianInfo = res.data
						this.getRenwuList();
					} else {
						// this.$message.error(res.status.msg);
						this.msgTextTow = res.status.msg;
						this.isShowLoadingTeow = true;
						setTimeout(() => {
							this.isShowLoadingTeow = false;
						}, 2000)
						// this.$message({
						// 	showClose: true,
						// 	message: res.status.msg,
						// 	type: 'error'
						// });
					}
				}).catch((err) => {
					console.log(err, 'err')
				});
			},
			getRenwuList() {
				let data = {}
				renwuList(data).then((res) => {
					if (res.status.errorCode == 0) {
						res.data.forEach((it, index) => {
							if (!it.wanchen) {
								if (it.user_num == 0 || it.user_num == 0.00) {
									it.widthSize = 0 + '%'
								} else if (parseFloat(it.user_num) > parseFloat(it.num) || parseFloat(it
										.user_num) == parseFloat(it.num)) {
									it.widthSize = 100 + '%'
								} else {
									it.widthSize = (parseFloat(parseInt(it.user_num) / parseInt(it.num))
										.toFixed(2)) * 100 + '%'
								}
							}
						})
						this.renWuList = res.data;
						this.isShowLoading = false;
					} else {
						// this.$message.error(res.status.msg);
						this.msgTextTow = res.status.msg;
						this.isShowLoadingTeow = true;
						setTimeout(() => {
							this.isShowLoadingTeow = false;
						}, 2000)
						// this.$message({
						// 	showClose: true,
						// 	message: res.status.msg,
						// 	type: 'error'
						// });
					}
				}).catch((err) => {
					console.log(err, 'err')
				});
			},
			submitRenwu(it) {
				let data = {
					id: it.id
				}
				renwuSubmit(data).then((res) => {
					if (res.status.errorCode == 0) {
						this.renWuList = [];
						this.getRenwuList();
					} else {
						// this.$message.error(res.status.msg);
						this.msgTextTow = res.status.msg;
						this.isShowLoadingTeow = true;
						setTimeout(() => {
							this.isShowLoadingTeow = false;
						}, 2000)
						// this.$message({
						// 	showClose: true,
						// 	message: res.status.msg,
						// 	type: 'error'
						// });
					}
				}).catch((err) => {
					console.log(err, 'err')
				})
			},
			getqiandao(it) {
				let data = {
					data: it.money
				}
				qiandao(data).then((res) => {
					console.log(res);
					if (res.status.errorCode == 0) {
						this.chongzhilianInfo = {};
						this.getchongzhilian();
					} else {
						// this.$message.error(res.status.msg);
						this.msgTextTow = res.status.msg;
						this.isShowLoadingTeow = true;
						setTimeout(() => {
							this.isShowLoadingTeow = false;
						}, 2000)
						// this.$message({
						// 	showClose: true,
						// 	message: res.status.msg,
						// 	type: 'error'
						// });
					}
				}).catch((err) => {
					console.log(err, 'err')
				});
			},
			changetab(e) {
				console.log(e);
				this.tab = e;
				if (e == 0) {
					this.isShowLoading = true;
					this.getqiandaoTianshuList();
					this.getchongzhilian();
				} else if (e == 3) {
					this.$refs["indexTowThree"].isShowLoading = true
				}
			},
			goBack() {
				this.$router.go(-1)
			}
		}
	}
</script>

<style scoped>
	* {
		box-sizing: border-box;
		margin: 0;
		padding: 0;
	}

	.conPpageBox {
		height: 90vh;
		overflow-y: auto;
		overflow-x: hidden;
		padding-top: calc(constant(safe-area-inset-top) + 0px);
		padding-top: calc(env(safe-area-inset-top) + 0px);
		padding-bottom: calc(constant(safe-area-inset-bottom) + 85px);
		padding-bottom: calc(env(safe-area-inset-bottom) + 85px);
		box-sizing: border-box;
		position: fixed;
		z-index: 1;
		-webkit-overflow-scrolling: touch;
		width: 100%;
	}

	.swiper {
		width: 100%;
		margin-bottom: 20px;
	}

	.swiper-slide {
		position: relative;
	}

	.heziBoxIt {
		width: 335px !important;
		position: relative;
		margin: 70px auto 0;
		/* border: 1px solid #fcfcfc33; */
		border: 1px solid #99999933;
		border-radius: 20px;
	}

	.heziBoxItTow {}

	.heziBoxItLine {
		background-color: #999999;
		width: 100%;
		height: 20px;
		border-radius: 20px 20px 0 0;
	}

	.heziBoxItLineTow {
		background-color: linear-gradient(90deg, #feef9c 0%, #e6b811 100%);
	}

	.baoxiangkaiHH {
		position: absolute;
		top: -60px;
		left: 50%;
		transform: translateX(-50%);
	}

	.baoxiangkai {
		width: 130px;
		height: 130px;
		animation: scale-breathe 2s infinite linear;
	}

	@keyframes scale-breathe {
		0% {
			transform: scale(1);
		}

		25% {
			transform: scale(1.1);
		}

		75% {
			transform: scale(0.9);
		}

		100% {
			transform: scale(1);
		}
	}

	.heziTow {
		width: 100%;
		padding: 50px 0px 25px;
		box-sizing: border-box;
	}

	.heziTowBox {
		width: 100%;
	}

	.heziTowBoxDay {
		color: #333;
		text-align: center;
		font-size: 18px;
	}

	.heziTowBoxNum {
		text-align: center;
		color: #9f855b;
		font-size: 20px;
		margin: 10px 0px 15px;
	}

	.heziTowBoxNum span {
		margin-left: 5px;
	}

	.qiandaotiaojian {
		color: #333;
		text-align: center;
		font-size: 15px;
	}

	.dangriBox {
		width: 90%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 15px auto 0;
	}

	.dangriBoxTitle {
		color: #333;
		font-size: 15px;
	}

	.dangriBoxRight {
		color: #333;
		display: flex;
		align-items: center;
		font-size: 15px;
	}

	.dangriBoxRight span {
		color: #9f855b;
	}

	.dangriBoxRightss {
		margin-left: 5px;
	}

	.dangriBoxRightTow {
		color: #38c522;
		font-size: 15px;
	}

	.renzhengBox {
		text-align: center;
		margin: 30px 0px 15px;
		color: #ff4343;
		font-size: 15px;
	}

	.renzhengBoxdd {
		height: 85px;
		color: #fff;
		box-sizing: border-box;
	}

	.navbar {
		background-color: #fff;
		box-shadow: inset 0 -1px 0 #ececec;
		color: #545658;
		height: 45px;
		left: 0;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: fixed;
		padding: 0 10px;
		top: 0;
		width: 100%;
		z-index: 99;
	}

	.hearderBoxIcon {
		flex: .25;
		line-height: 1;
	}

	.hearderBoxIcon img {
		width: 26px;
		height: 26px;
	}

	.title {
		flex: 1;
		font-size: 20px;
		line-height: 1;
		text-align: center;
	}

	.right {
		flex: .25;
	}

	.nrc-tabs {
		background-color: #fff;
		margin-top: 45px;
	}

	.nrc-tabs-nav {
		align-items: center;
		display: flex;
		background-color: #fff;
		border-bottom-color: #e9e9e9;
		justify-content: space-evenly;
	}

	.nrc-tabs-tab {
		flex: 1;
		font-weight: 400;
		line-height: unset;
		box-sizing: border-box;
		display: block;
		font-size: 16px;
		font-stretch: normal;
		font-style: normal;
		text-align: center;
		min-width: 65px;
		padding: 8px;
	}

	.nrc-tabs-tab.active {
		background-image: unset;
		border-bottom: 2px solid #7240ff;
		color: #7240ff;
	}

	.history-cards-wrapper {
		display: flex;
		flex-direction: column;
		height: 100%;
		padding: 15px 10px 0;
	}

	.mission-period {
		color: #5235ff;
		font-size: 14px;
		padding-bottom: 10px;
	}

	.mission-periodlll {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.item {
		height: 110px;
		width: 100%;
		margin-bottom: 20px;
		background-color: #fafafc;
		border-radius: 5px;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		font-size: 14px;
		justify-content: space-between;
		padding: 15px;
	}

	.mission-title {
		color: #545658;
		font-size: 16px;
		font-weight: 400;
		line-height: 16px;
		margin-bottom: 6px;
	}

	.mission-threshold-progress {
		display: flex;
		font-size: 14px;
		justify-content: space-between;
	}

	.threshold-text {
		color: #939698;
		flex: 1;
		line-height: 18px;
		padding: 0 3px 0 0;
	}

	.progress-box {
		align-items: center;
		display: flex;
		margin-left: 8px;
	}

	.progress-text {
		color: #939698;
		font-size: 10px;
	}

	.progress-bar {
		border: 1px solid #ffba00;
		border-radius: 20px;
		height: 10px;
		margin-left: 5px;
		overflow: hidden;
		width: 60px;
	}

	.progress-line {
		background-color: #ffba00;
		height: 10px;
	}

	.reward-row {
		align-items: center;
		color: #5235ff;
		display: flex;
		font-size: 12px;
		justify-content: space-between;
	}


	.progress-box.completed .progress-bar {
		border: 1px solid #75943e;
	}

	.progress-box.completed .progress-bar .progress-line {
		background-color: #75943e;
	}

	/deep/ .el-button {
		background-color: #5235ff;
		border-radius: 10px;
		color: #fff;
		font-size: 12px;
		padding: 3px 12px;
		background-image: none;
		box-shadow: none;
		height: 30px;
		min-width: 25%;
	}

	.no-data-container {
		color: #545658;
		display: flex;
		flex-direction: column;
		font-size: 16px;
		justify-content: center;
		min-height: calc(100vh - 117px);
		opacity: .6;
		text-align: center;
	}

	.buttons {
		position: fixed;
		bottom: 10%;
		right: 10px;
		background-color: #99D2E3;
		width: 60px;
		height: 60px;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.buttons img {
		width: 32px;
		height: 32px;
	}

	.event-qmenu {
		bottom: 100px;
		height: auto !important;
		left: 0;
		min-height: auto !important;
		position: fixed;
		transition: .3s ease;
		width: 100px;
		z-index: 21;
	}

	.event-qmenu.close {
		transform: translateX(-73px);
	}

	.handle {
		bottom: 5px;
		height: 84px;
		position: absolute;
		right: 3px;
		width: 30px;
	}

	svg:not(:root) {
		overflow: hidden;
	}

	.event-qmenu .handle path {
		fill: #7240ff;
	}

	.handle img {
		bottom: 28px;
		position: absolute;
		right: 3px;
		width: 25px;
		height: 25px;
	}

	/* .handle::after {
		speak: none;
		color: #fff;
		content: ">";
		font-family: iconmps !important;
		font-size: 20px;
		font-style: normal;
		font-variant: normal;
		font-weight: 400;
		left: -2px;
		line-height: 1;
		position: absolute;
		text-align: center;
		text-shadow: 0 -1px 3px #4c0dff;
		text-transform: none;
		top: 50%;
		transform: translateY(-50%) rotate(180deg);
		width: 30px;
	} */

	.event-qmenu.close .handle::after {
		left: 0px;
		text-shadow: 0 1px 3px #4c0dff;
		transform: translateY(-50%) rotate(0deg);
	}

	@keyframes aqm {
		0% {
			box-shadow: 0 2px 6px rgba(0, 0, 0, .8);
		}

		55% {
			box-shadow: 0 2px 4px #aa8dff;
		}

		70% {
			box-shadow: 0 2px 4px #bda6ff;
		}

		100% {
			box-shadow: 0 2px 6px rgba(0, 0, 0, .8);
		}
	}

	.cont {
		align-items: center;
		animation: aqm 1.8s ease infinite;
		background-color: rgba(0, 0, 0, .8);
		border: 3px solid #7240ff;
		border-bottom-right-radius: 15px;
		border-left: 0;
		border-top-right-radius: 15px;
		box-shadow: 0 2px 6px rgba(0, 0, 0, .8);
		display: flex;
		flex-wrap: wrap;
		min-height: 103px;
		padding: 10px;
		width: 70px;
	}

	.event-item {
		align-items: center;
		display: flex;
		height: 50px;
		justify-content: center;
		margin: 5px 0;
		position: relative;
		transition: .3s ease;
		width: 50px;
	}

	.event-item img {
		display: block;
		max-height: 100%;
		max-width: 100%;
	}

	.qiandaoBox {
		width: 100%;
	}

	.qiandaoBoxTit {
		font-size: 20px;
		color: #333;
		text-align: center;
	}

	.qiandaoBoxBor {
		width: 90%;
		margin: 20px auto;
		height: 85px;
		padding: 15px 0px;
		box-sizing: border-box;
		border: 1px solid rgba(102, 102, 102, 0.5);
		background-color: rgba(39, 39, 41, 0.3);
		border-radius: 37px;
	}

	.qiandaoBoxBorIt {
		text-align: center;
		color: #ffffff;
		font-size: 14px;
	}

	.qiBoxBorItTow {
		text-align: center;
		color: #ffffff;
		font-size: 14px;
		margin-top: 10px;
	}

	.jiangjinTow {
		font-size: 20px;
		color: #9f855b;
		margin-left: 15px;
	}

	.zhongbiBox {
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 12px;
		color: #999;
	}

	.zhongbiBox img {
		width: 25px;
		height: 25px;
		margin-left: 15px;
	}

	.heziBox {
		width: 100%;
		margin-bottom: 20px;
	}



	/deep/ .elButton {
		background-color: #5235ff;
		border-radius: 45px;
		color: #fff;
		font-size: 12px;
		padding: 3px 12px;
		background-image: none;
		box-shadow: none;
		height: 45px;
		min-width: 120px;
	}

	/deep/ .asdfas {
		background-color: #939698;
	}

	.dafad {
		display: flex;
		justify-content: center;
	}
</style>